﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;

using BrightIdeasSoftware;


namespace PresentationLayer
{
    public partial class PublicPrintObjectListView : Form
    {
        public PublicPrintObjectListView(DataListView dataListView)
        {
            InitializeComponent();

            this.listViewPrinter1.ListView = dataListView;

            //this.listViewPrinter1.DocumentName = this.tbTitle.Text;
            //this.listViewPrinter1.Header = this.tbHeader.Text.Replace("\\t", "\t");
            //this.listViewPrinter1.Footer = this.tbFooter.Text.Replace("\\t", "\t");
            //this.listViewPrinter1.Watermark = this.tbWatermark.Text;

            //this.listViewPrinter1.IsShrinkToFit = this.cbShrinkToFit.Checked;
            //this.listViewPrinter1.IsTextOnly = !this.cbIncludeImages.Checked;
            //this.listViewPrinter1.IsPrintSelectionOnly = this.cbPrintOnlySelection.Checked;

            //if (this.rbStyleMinimal.Checked == true)
            this.ApplyMinimalFormatting();
            //else if (this.rbStyleModern.Checked == true)
            //    this.ApplyModernFormatting();
            //else if (this.rbStyleTooMuch.Checked == true)
            //    this.ApplyOverTheTopFormatting();

            //if (this.cbCellGridLines.Checked == false)
            this.listViewPrinter1.ListGridPen = null;

            //this.listViewPrinter1.FirstPage = (int)this.numericUpDown1.Value;
            //this.listViewPrinter1.LastPage = (int)this.numericUpDown2.Value;

            this.printPreviewControl1.Zoom = 1;
            this.printPreviewControl1.AutoZoom = true;

            this.printPreviewControl1.Document = this.listViewPrinter1;
            this.printPreviewControl1.InvalidatePreview();

        }

        public void ApplyMinimalFormatting()
        {
            this.listViewPrinter1.CellFormat = null;
            this.listViewPrinter1.ListFont = new Font("Tahoma", 9);

            this.listViewPrinter1.HeaderFormat = BlockFormat.Header();
            this.listViewPrinter1.HeaderFormat.TextBrush = Brushes.Black;
            this.listViewPrinter1.HeaderFormat.BackgroundBrush = null;
            this.listViewPrinter1.HeaderFormat.SetBorderPen(Sides.Bottom, new Pen(Color.Black, 0.5f));

            this.listViewPrinter1.FooterFormat = BlockFormat.Footer();
            this.listViewPrinter1.GroupHeaderFormat = BlockFormat.GroupHeader();
            Brush brush = new LinearGradientBrush(new Point(0, 0), new Point(200, 0), Color.Gray, Color.White);
            this.listViewPrinter1.GroupHeaderFormat.SetBorder(Sides.Bottom, 2, brush);

            this.listViewPrinter1.ListHeaderFormat = BlockFormat.ListHeader();
            this.listViewPrinter1.ListHeaderFormat.BackgroundBrush = null;

            this.listViewPrinter1.WatermarkFont = null;
            this.listViewPrinter1.WatermarkColor = Color.Empty;
        }

        private void button11_Click(object sender, EventArgs e)
        {
            this.listViewPrinter1.PageSetup();
            //this.printPreviewControl1.InvalidatePreview();
            this.listViewPrinter1.PrintPreview();
        }

    }
}
